<template>
  <div id="studySchedule">
    <section class="header">
      <h1>学习进度</h1>
      <aside>
        <span>选择人员：{{ username }}</span>
        <span><router-link to="/study/uploadProgress">点我上传进度哦！</router-link></span>
      </aside>
    </section>
    <a-empty v-if="empty" description="暂无学习进度"/>
    <a-spin size="large" v-if="spinning"/>
    <section class="schedule-wrap" v-cloak>
      <div class="schedule-list" v-for="(item,index) in schedule">
        <div class="schedule-img">
          <img :src="item.img" alt="">
        </div>
        <div class="schedule-order">
          <div>{{ index + 1 }}</div>
        </div>
        <div class="schedule-content">
          <p>{{ item.content }}</p>
        </div>
      </div>
    </section>

  </div>
</template>

<script>
import {defineComponent, getCurrentInstance, onMounted, ref} from "vue";

export default defineComponent({
  name: "studySchedule",
  setup() {
    const {proxy} = getCurrentInstance();
    let username = ref();
    let empty = ref(false);
    let spinning = ref(false)
    let schedule = ref()
    proxy.$request(proxy.$getRoute(8).route_method, proxy.$getRoute(8).route_url, {}).then(res => {
      username.value = res.data.username;
    })

    proxy.$request(proxy.$getRoute(101).route_method, proxy.$getRoute(101).route_url, {}).then(res => {
      schedule.value = res.data

      if (res.data.length === 0) {
        empty.value = true
      }
    })
    onMounted(() => {
      spinning.value = false
    })
    return {
      schedule,
      username,
      empty,
      spinning
    }
  }
})
</script>

<style lang="less">
body {
  //background: #F5F5F5;
  background: #FFF;
}

ul {
  list-style: none;
}

[v-cloak] {
  display: none;
}

#studySchedule {
  width: 1200px;
  min-height: 92vh;
  margin: 0 auto;
  padding-top: 65px;
  box-sizing: border-box;

  .header {
    width: 100%;
    height: 184px;
    background: #FFFFFF;
    border-radius: 0px 0px 16px 16px;
    display: flex;
    flex-direction: column;
    padding: 0 30px;
    box-sizing: border-box;

    h1 {
      font-size: 36px;
      font-family: PingFang SC-Medium, PingFang SC;
      font-weight: 500;
      color: #262626;
      line-height: 54px;
      margin: 40px auto 32px;
    }

    aside {
      width: 360px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin: 0 auto;

      span {
        font-size: 16px;
        font-family: PingFang SC-Medium, PingFang SC;
        font-weight: 500;
        color: #6777EF;
        line-height: 19px;
        cursor: pointer;

        &:first-child {
          display: block;
          color: #465059;
          cursor: default;
        }
      }
    }
  }

  .schedule-wrap {
    width: 730px;
    margin: 0 auto 40px;
    //background: #8B8B8B;
  }

  .schedule-list {
    width: 100%;
    height: 240px;
    display: flex;
    justify-content: space-between;

    &:nth-child(odd) {
      flex-direction: row;
    }

    &:nth-child(even) {
      flex-direction: row-reverse;
    }

    //justify-content: center;

    .schedule-img {
      width: 270px;
      height: 220px;
      //background: #C4C4C4;
      text-align: center;

      img {
        width: auto;
        max-width: 270px;
        max-height: 220px;
        height: auto;
      }
    }

    .schedule-content {
      width: 270px;
      height: 220px;
      overflow: hidden;
      //background: #d2d2d2;

      p {
        font-size: 14px;
        font-family: PingFang SC-Medium, PingFang SC;
        font-weight: 500;
        color: #465059;
        line-height: 20px;
      }
    }

    .schedule-order {
      width: 50px;
      height: 100%;
      display: flex;
      flex-direction: column;

      div {
        width: 50px;
        height: 50px;
        text-align: center;
        line-height: 46px;
        border-radius: 50%;
        border: 2px solid #EEEEEE;
        font-size: 18px;
        color: #6777EF;
        background-color: #FFF;
        box-sizing: border-box;
        user-select: none
      }

      &::after {
        content: "";
        display: block;
        width: 2px;
        margin: 14px auto;
        height: 160px;
        background: #C4BEFE;
      }
    }
  }

  .ant-spin {
    margin-top: 20px;
    display: flex;
    justify-content: center;
  }
}
</style>